package core

import (
	"database/sql/driver"
	"errors"
	"encoding/json"
)

type StringList []string


func (l StringList) Value() (driver.Value, error)  {
	return json.Marshal(l)
}

func (l *StringList) Scan(src interface{}) error {
	if src == nil {
		*l = make(StringList, 0)
		return nil
	}
	v,ok := src.([]byte)
	if !ok {
		return errors.New("bad []byte type assertion")
	}
	return json.Unmarshal(v, l)
}